package com.bbird.od.finance.service.models;

import com.alibaba.excel.annotation.ExcelProperty;
import com.bbird.od.finance.service.models.excel.EnumToExcelConverter;
import com.bbird.od.finance.service.models.type.BankCostType;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author ziyang Kuang
 * @date 2020/11/16
 * @describe
 */
@Data
public class PDDBankFlow extends BankFlow {
    // 商户订单号
    @ExcelProperty("商户订单号")
    private String businessOrderNumber;
    // 发生时间
    @ExcelProperty("发生时间")
    private Date costProduceTime;
    // 收入金额
    @ExcelProperty("收入金额（+元）")
    private BigDecimal incomeAmount;
    // 支出金额
    @ExcelProperty("支出金额（-元）")
    private BigDecimal outputAmount;
    // 账务类型
    @ExcelProperty(value = "账务类型", converter = EnumToExcelConverter.class)
    private BankCostType costType;
    // 分类
    @ExcelProperty("分类")
    private String billClassify;

    @Override
    public BigDecimal getActualAmount() {
        if (incomeAmount != null && outputAmount != null) {
            return incomeAmount.add(outputAmount);
        }
        return BigDecimal.ZERO;
    }

    @Override
    public String getHomeOrderNumber(){
        return this.businessOrderNumber;
    }
}
